﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test1
{
    class Program
    {
        static void Main(string[] args)
        {
            int num;
            HashSet<int> intSet = new HashSet<int>();
            do
            {
                Console.Write("请输入一个大于1的正整数:");
                try
                {
                    num = Int32.Parse(Console.ReadLine());
                }
                catch (Exception e)
                {
                    Console.WriteLine("出现未知错误");
                    num = 0;
                }
            } while (num<=1);
            //从最小素数2开始循环
            for(int i = 2; num > 1; )
            {
                if (num % i == 0)
                {
                    num = num / i;
                    intSet.Add(i);
                }
                else
                {
                    ++i;
                }
            }
            //遍历输出所有素数因子
            foreach(int x in intSet)
            {
                Console.Write(x+" ");
            }
            Console.ReadKey();
        }
    }
}
